package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.SpecValue;
import com.nbsaas.boot.product.api.domain.request.SpecValueRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.product.data.entity.Spec;

/**
* 规格值请求对象转换成实体对象
*/

public class SpecValueEntityConvert  implements Converter<SpecValue, SpecValueRequest> {

    @Override
    public SpecValue convert(SpecValueRequest source) {
        SpecValue result = new SpecValue();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getSpec()!=null){
                    Spec spec =new Spec();
                    spec.setId(source.getSpec());
                    result.setSpec(spec);
                    }
        return result;
    }
}

